package com.ruoyi.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pm.domain.SaasSupplierMain;
import com.ruoyi.pm.service.ISaasSupplierMainService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 保司自定义加密方法Controller
 * 
 * @author ruoyi
 * @date 2022-03-22
 */
@RestController
@RequestMapping("/pm/supplierMain")
public class SaasSupplierMainController extends BaseController
{
    @Autowired
    private ISaasSupplierMainService saasSupplierMainService;

    /**
     * 查询保司自定义加密方法列表
     */
    @PreAuthorize("@ss.hasPermi('pm:supplierMain:list')")
    @GetMapping("/list")
    public TableDataInfo list(SaasSupplierMain saasSupplierMain)
    {
        startPage();
        List<SaasSupplierMain> list = saasSupplierMainService.selectSaasSupplierMainList(saasSupplierMain);
        return getDataTable(list);
    }

    /**
     * 查询保司自定义加密方法列表
     */
    @PreAuthorize("@ss.hasPermi('pm:supplierMain:list')")
    @GetMapping("/listBySupplierId/{supplierId}")
    public AjaxResult list(@PathVariable Long supplierId)
    {
        return AjaxResult.success(saasSupplierMainService.listBySupplierId(supplierId));
    }

    /**
     * 导出保司自定义加密方法列表
     */
    @PreAuthorize("@ss.hasPermi('pm:supplierMain:export')")
    @Log(title = "保司自定义加密方法", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SaasSupplierMain saasSupplierMain)
    {
        List<SaasSupplierMain> list = saasSupplierMainService.selectSaasSupplierMainList(saasSupplierMain);
        ExcelUtil<SaasSupplierMain> util = new ExcelUtil<SaasSupplierMain>(SaasSupplierMain.class);
        util.exportExcel(response, list, "保司自定义加密方法数据");
    }

    /**
     * 获取保司自定义加密方法详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:supplierMain:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(saasSupplierMainService.selectSaasSupplierMainById(id));
    }

    /**
     * 新增保司自定义加密方法
     */
    @PreAuthorize("@ss.hasPermi('pm:supplierMain:add')")
    @Log(title = "保司自定义加密方法", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SaasSupplierMain saasSupplierMain)
    {
        return toAjax(saasSupplierMainService.insertSaasSupplierMain(saasSupplierMain));
    }

    /**
     * 修改保司自定义加密方法
     */
    @PreAuthorize("@ss.hasPermi('pm:supplierMain:edit')")
    @Log(title = "保司自定义加密方法", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SaasSupplierMain saasSupplierMain)
    {
        return toAjax(saasSupplierMainService.updateSaasSupplierMain(saasSupplierMain));
    }

    /**
     * 删除保司自定义加密方法
     */
    @PreAuthorize("@ss.hasPermi('pm:supplierMain:remove')")
    @Log(title = "保司自定义加密方法", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(saasSupplierMainService.deleteSaasSupplierMainByIds(ids));
    }
}
